#pragma once

#include <DShow.h>
#include <comdef.h>
#define COM_SMARTPTR_TYPEDEF(x) _COM_SMARTPTR_TYPEDEF(x,__uuidof(x))

COM_SMARTPTR_TYPEDEF(IGraphBuilder);
COM_SMARTPTR_TYPEDEF(IMediaControl);
COM_SMARTPTR_TYPEDEF(IMediaSeeking);
COM_SMARTPTR_TYPEDEF(IBasicAudio);
COM_SMARTPTR_TYPEDEF(IMediaEventEx);

class CDShowAudio
{
public:
	CDShowAudio(void);
	~CDShowAudio(void);

	HRESULT init();
	void release();
	void setNotifyWindow(HWND hWnd);

	int open(const TCHAR *fname);

	void start();
	void pause();
	void stop();
	
	BOOL setVolume(float x);
	BOOL setRate(float r);
	BOOL m_bLoop;
	
	BOOL seek(int p);
	int tell();

	void onNotify();

protected:
	IGraphBuilderPtr m_graphBuilder;
	IMediaControlPtr m_mediaControl;
	IMediaSeekingPtr m_mediaSeeking;
	IBasicAudioPtr m_basicAudio;
	IMediaEventExPtr m_mediaEvent;

	int m_iPlay;
};
